<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
	xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
<meta charset="UTF-8" />
<title>Title</title>
<link rel="stylesheet" href="css/bootstrap.css" />
<link rel="stylesheet" href="css/bootstrap-theme.css" />
<link href="css/alertify.core.css" rel="stylesheet" id="toggleCSS">
<link rel="stylesheet" href="css/new2.css" />

</head>
<body>
	<div class="container">
		<div class="align-center" id="divform">
			<form class="form-horizontal" id="buildingform"><!-- 表单 -->
				<!--11111111111111111111111-->
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group form-group-sm">
							<label class="col-xs-4 control-label">父级编码</label>
							<div class="col-xs-8">
								<select id="banRegionId" class="form-control input-sm" name="banRegionId" >
									<option>请选择</option>
									<option 
										th:each="regionCode : ${regionCodeList}"
										th:value="${regionCode.regId}"
										th:text="${regionCode.regCode}">加载中...
									</option>
								</select>
							</div>
						</div>
					</div>

					<div class="col-xs-6">
						<div class="form-group form-group-sm">
							<label class="col-xs-4 control-label"><span class="sb">楼栋编码</span></label>
							<div class="col-xs-8">
								<input id="banCode" name="banCode" class="form-control input-sm" type="text" placeholder="" />
							</div>
						</div>
					</div>
				</div>

				<!--2222222222222222222222-->
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group form-group-sm">
							<label class="col-xs-4 control-label"><span class="sb">楼栋名称</span></label>
							<div class="col-xs-8">
								<input id="banName" name="banName" class="form-control input-sm" type="text" placeholder="" />
							</div>
						</div>
					</div>

					<div class="col-xs-6">
						<div class="form-group form-group-sm">
							<label class="col-xs-4 control-label"><span class="sb">租售类型</span></label>
							<div class="col-xs-8">
								<select id="banTypeName" name="banTypeName" class="form-control input-sm">
									<option value="出售">出售</option>
									<option value="出租">出租</option>
									<option value="租售">租售</option>
								</select>
							</div>
						</div>
					</div>
				</div>


				<!--333333333333333-->
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group form-group-sm">
							<label class="col-xs-4 control-label">销控显示 </label>
							<div class="col-xs-8">
								<select id="banControl" name="banControl" class="form-control input-sm">
									<!-- <option value="">请选择显示类型</option> -->
									<option value="销控表">销控表</option>
									<option value="平面图 ">平面图 </option>
								</select>
								<!-- <div class="checkbox">
									<label> <input type="checkbox" name="banControl"/> 销控表 </label> 
									<label> <input type="checkbox" name="banControl"/> 平面图 </label>
								</div> -->
							</div>
						</div>
					</div>

					<div class="col-xs-6">
						<div class="form-group form-group-sm">
							<label class="col-xs-4 control-label">销售许可证编号</label>
							<div class="col-xs-8">
								<input id="banControlLicenseNumber" name="banControlLicenseNumber" class="form-control input-sm" type="text" placeholder="" />
							</div>
						</div>
					</div>
				</div>

				<!--666666-->
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group form-group-sm">
							<label class="col-xs-4 control-label">销售许可证日期</label>
							<div class="col-xs-8">
								<input id="banControlLicenseDate" name="banControlLicenseDate" class="form-control input-sm" type="date" placeholder="" />
							</div>
						</div>
					</div>

					<div class="col-xs-6">
						<div class="form-group form-group-sm">
							<label class="col-xs-4 control-label">竣备编号</label>
							<div class="col-xs-8">
								<input id="banPreparationMethodNumber" name="banPreparationMethodNumber" class="form-control input-sm" type="text" placeholder="" />
							</div>
						</div>
					</div>
				</div>

				<!--777777-->
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group form-group-sm">
							<label class="col-xs-4 control-label">竣备日期</label>
							<div class="col-xs-8">
								<input id="banPreparationMethodDate" name="banPreparationMethodDate" class="form-control input-sm" type="date" placeholder="" />
							</div>
						</div>
					</div>

					<div class="col-xs-6">
						<div class="form-group form-group-sm">
							<label class="col-xs-4 control-label">预计交房日期</label>
							<div class="col-xs-8">
								<input id="banExpectedDeliveryDate" name="banExpectedDeliveryDate" class="form-control input-sm" type="date" placeholder="" />
							</div>
						</div>
					</div>
				</div>

				<!--8888888-->
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group form-group-sm">
							<div class="col-xs-8"></div>
							<!-- <input id="banExpectedDeliveryDate" name="banExpectedDeliveryDate" value="0"  type="hidden" />
							<input id="banExpectedDeliveryDate" name="banExpectedDeliveryDate" value="0"  type="hidden" />
							<input id="banExpectedDeliveryDate" name="banExpectedDeliveryDate" value="0"  type="hidden" />  --> 
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-offset-11 col-sm-1">
						<button type="button" class="btn btn-default" onclick="addBuliding();">保存</button>
					</div>
				</div>
			</form>
		</div>
	</div>

	<!-- async属性了。（默认的true是异步），false是同步。 -->
	<script src="js/jquery.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/alertify.min.js"></script>
   	<script src="layer/jquery.min.js"></script>
   	<script src="layer/layer.js"></script>

<script type="text/javascript">

	function addBuliding(){
		var banRegionId = document.getElementById("banRegionId").value;
		var banCode = document.getElementById("banCode").value;
		var banName = document.getElementById("banName").value;
		var banTypeName = document.getElementById("banTypeName").value;
		var banControl = document.getElementById("banControl").value;
		var banControlLicenseNumber = document.getElementById("banControlLicenseNumber").value;
		var banControlLicenseDate = document.getElementById("banControlLicenseDate").value;
		var banPreparationMethodNumber = document.getElementById("banPreparationMethodNumber").value;
		var banPreparationMethodDate = document.getElementById("banPreparationMethodDate").value;
		var banExpectedDeliveryDate = document.getElementById("banExpectedDeliveryDate").value;
		//alert(diyId+banCode);
		
		var result = new Object();
		result.banRegionId = banRegionId;
		result.banCode = banCode;
		result.banName = banName;
		result.banTypeName = banTypeName;
		result.banControl = banControl;
		result.banControlLicenseNumber = banControlLicenseNumber;
		result.banControlLicenseDate = banControlLicenseDate;
		result.banPreparationMethodNumber = banPreparationMethodNumber;
		result.banPreparationMethodDate = banPreparationMethodDate;
		result.banExpectedDeliveryDate = banExpectedDeliveryDate;
		
		var formData = JSON.stringify(result);//把对象转换json格式 
		 
		debugger
		$.ajax({
			type : "POST",
 			url : "/addBuild",
 			dataType : "json",
 			clearForm : true,
 			data : formData,
 			processData : false,
 			traditional: true,
 			contentType:'application/json;charset=UTF-8',
 			success : function(data) {
 				debugger;
 				if (data.num == true ) {
 					debugger;
 					alert("添加成功!");
 					layer.close(layer.index);  
 			        window.parent.location.reload();
 				} else if(data.num == false ){ 
 					debugger;
 					alert("添加失败!");
 				}
 			}
		});
	};
		
</script>

</body>
</html>